package com.project.platform.mapper;

import com.project.platform.entity.Admin;
import com.project.platform.entity.Elder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;


public interface ElderMapper {
    List<Elder> queryPage(Integer offset, Integer pageSize, @Param("query") Map<String, Object> query);

    int queryCount(@Param("query") Map<String, Object> query);

    @Select("SELECT * FROM elder WHERE id = #{id}")
    Elder selectById(Integer id);

    @Select("SELECT * FROM elder")
    List<Elder> list();

    int insert(Elder entity);

    int updateById(Elder entity);

    boolean removeByIds(List<Integer> ids);

    @Select("SELECT * FROM elder WHERE username = #{username}")
    Elder selectByUserName(String username);

    @Select("SELECT * FROM elder WHERE tel = #{tel}")
    Elder selectByTel(String tel);

    @Select("SELECT * FROM elder WHERE family_id = #{id}")
    Elder selectByFamilyId(Integer id);

    @Select("SELECT * FROM elder WHERE building_id = #{id}")
    List<Elder> selectByBuildingId(Integer id);

    List<Elder> selectByRoomIds(List<Integer> idList);

    @Update("UPDATE `elder` SET building_id = null ,room_id = null WHERE id = #{id}")
    int updateBuildingIdAndRoomId(Integer id);
}